﻿﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
        <script type="text/javascript" src="lib/html5shiv.js"></script>
        <script type="text/javascript" src="lib/respond.min.js"></script>
        <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="./../lib/layui/css/layui.css">
    <!--[if IE 6]>
        <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
        <style>
        .layui-table-view .layui-form-checkbox,.layui-table-cell .layui-form-checkbox[lay-skin=primary]{
            top:0
        }
        </style>
    <title>用户列表</title>
</head>

<body>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span>
		用户列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
		 title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="page-container">
		<div class="">
			<label for="">用户名：</label>
			<input type="text" class="input-text" style="width:150px" placeholder="输入用户名" id="userName" name="">
			<!-- 上级账号： -->
			<!-- <input type="text" class="input-text" style="width:150px" placeholder="输入上级账号" id="pollCode" name=""> -->
			<label for="">手机号：</label>
			<input type="text" class="input-text" style="width:150px" placeholder="输入手机号" id="mobile" name="">
			<button type="submit" class="btn btn-success" name="" data-type="reload" id="searach"><i class="Hui-iconfont">&#xe665;</i>
                搜用户</button>
                <button  class="btn btn-success" onclick="addUser()">新增用户</button>
		</div>
		<table class="layui-hide" id="member" lay-filter="member"></table>
	</div>
	<div class="mt-20"></div>

	</div>
	<div id="pager" class="clearfix"></div> 
	<!--<input type="" name="pagernum" id="pagernum" value="1" style="display:block;"/>-->
	<input type="" name="details_id" id="details_id" value="" style="display:none;" />
	<!--_footer 作为公共模版分离出去-->
	<script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="./../static/js/common.js"></script>
	<script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
	<script type="text/javascript" src="./../lib/layui/layui.js"></script>

	<!--/_footer 作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="../lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<link rel="stylesheet" type="text/css" href="../lib/pager/Pager.css" />
	<script type="text/javascript" src="../lib/pager/jquery.pager.js"></script>
	<script type="text/html" id="operation">
		<a  title="修改" lay-event="edit-info" class=""><i class="Hui-iconfont">&#xe6df;</i></a>
		<a  title="加入黑名单" lay-event="blacklist"><i class="Hui-iconfont">&#xe716;</i></a>
		<a  title="重置登录密码" lay-event="login-pwd"><i class="Hui-iconfont">&#xe63f;</i></a>
		<a  title="重置交易密码" lay-event="trader-pwd"><i class="Hui-iconfont">&#xe60e;</i></a>
		<a title="资金流水" lay-event="capital-flow"><i class="Hui-iconfont">&#xe687;</i></a>
	  </script>
	<script type="text/javascript">
		layui.use('table', function () {
			var table = layui.table
				, form = layui.form;
			var InTable =  table.render({
				elem: '#member',
				url: admin_url + '/kvmUser/userList',
				cellMinWidth: 80,
				id: 'reload2',
				request: {
					pageName: 'page',
					limitName: 'size'
				},
				// 额外的数据参数
				where: {
					tokenUserId: userId,
					token: token
				},
				method: 'post',
				// 回调
				done: function (res, curr, count) {
					console.log(res)
					var data = res.data;
				},
				paresData: function (res) {
					return {
						'data': res.data
					}
				},
				response: {
					statusCode: 200
				},
				cols: [[
					{ checkbox: true, align: 'center' },
					{ field: 'id', title: 'ID', align: 'center', width: 80 }
					, { field: 'userName', title: '用户名', align: 'center' }
					, { field: 'nickName', title: '昵称', align: 'center' }
					, { field: 'lv', title: '等级', align: 'center' }
					, { field: 'mobile', title: '手机号', align: 'center' }
					, { field: 'pollCode', title: '上级账号', align: 'center' }
					, { field: 'name', title: '实名', align: 'center' }
					, { field: 'idCard', title: '身份证', align: 'center' }
					, { field: 'status', title: '状态', align: 'center',templet:function(obj){
						if(obj.status == 0){
							return '<span class="layui-badge layui-bg-green">正常</span>'
						}else if(obj.status == 1){
							return '<span class="layui-badge">冻结</span>'
						}else if(obj.status == 2){
							return '<span class="layui-badge layui-bg-orange">锁定</span>'
						}else{
                            return '<span></span>'
                        }
					} }
					, { toolbar: '#operation', title: '操作' }
				]],
				page: true
			})
			$("#searach").on("click", function () {
				InTable.reload({
					where: {
						"token": token,
						"tokenUserId": userId,
						"mobile": $("#mobile").val(),
						"userName": $("#userName").val(),
					}, page: {
                        curr: 1
                    }
				});
			})
			table.on('tool(member)', function (obj) {
				var data = obj.data;
				var id = data.id;
				console.log(id)
				if (obj.event === 'edit-info') {
					var index = layer.open({
						type: 2,
						title: '修改',
						id: id,
						content: './edit-info.html'
					})
					layer.full(index);
					$("#details_id").val(id)
				} else if (obj.event === 'blacklist') {

					layer.confirm("确定是否加入黑名单", function () {
						$.ajax({
							type: 'post',
							xhrFields: { withCredentials: true },
							url: admin_url + '/kvmUser/user2BlackList',
							data: { tokenUserId: userId, token: token, id: data.id },
							success: function (data) {
								if (data.code == 200) {
									layer.msg('添加成功', {
										time: 1000,
										end: function () {
										  $(".layui-laypage-btn").click();
										}
									})
								} else {
									layer.msg(data.msg, {
										time: 1500
									})
								}
							}
						})
					})
					// })
				} else if (obj.event === 'login-pwd') {
					var phone = Number(String(data.mobile).substr(5, 6))
					console.log(phone)
					layer.confirm("确认要重置该用户的 [登录密码] 为 [" + '7777777' + "] 吗？", function () {
						$.ajax({
							type: 'post',
							xhrFields: { withCredentials: true },
							url: admin_url + '/kvmUser/resetLoginPwd',
							data: { tokenUserId: userId, token: token, id: id },
							success: function (data) {
								if (data.code == 200) {
									layer.msg('重置登录密码成功', {
										time: 1000,
										end: function () {
                                            $(".layui-laypage-btn").click();
										}
									})
								} else {
									layer.msg('重置登录密码失败')
								}
							}
						})
					})
				}else if(obj.event === 'trader-pwd'){
					var tradePwd = 7777777
					layer.confirm("确认要重置该用户的 [交易密码] 为 [" + tradePwd + "] 吗？", function () {
						$.ajax({
							type: 'post',
							xhrFields: { withCredentials: true },
							url: admin_url + '/kvmUser/resetDealPwd',
							data: { tokenUserId: userId, token: token, id: id },
							success: function (data) {
								if (data.code == 200) {
									layer.msg('重置交易密码成功', {
										time: 1000,
										end: function () {
                                            $(".layui-laypage-btn").click();
										}
									})
								} else {
									layer.msg('重置交易密码失败')
								}
							}
						})
					})
				} else if (obj.event === 'capital-flow') {
					// var phone = Number(String(data.mobile).substr(5, 6))
					var index = layer.open({
						type: 2,
						title: '资金流水',
						id: id,
						content: './capital-flow.html'
					})
					layer.full(index);
					$("#details_id").val(id)
				}
				// layer.close(index);
			})
        })
        // 新增用户
        function addUser(){
            var index = layer.open({
				    type: 2,
					title: '新增用户',
					content: './add-user.html'
                })
                layer.full(index);
        }
	</script>
</body>

</html>